package com.fagejiang.springbootthymeleaf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Map;

/**
 * @author lin
 * @version 1.0
 * @date 2021/4/28 23:57
 * @Description TODO
 */
@Controller
public class PageController {

    @GetMapping("/")
    public String index() {
        return "index";
    }

    @GetMapping("/index")
    public String index2() {
        return "index";
    }

    @GetMapping("/get/get")
    @ResponseBody
    public String get() {
        return "success!";
    }

    @GetMapping("/get2")
    @ResponseBody
    public String get2() {
        return "success  22222!";
    }

    @GetMapping("/get3")
    @ResponseBody
    public String get3(@RequestHeader Map<String, Object> headers) {
        headers.forEach((k, v) -> {
            System.out.println(String.format("Header '%s' = %s", k, v));
        });
        return "success  3333!";
    }
}
